#ifndef __TMETHOD__
#define __TMETHOD__
#define _CRT_RAND_S
#include <stdlib.h>
#include <iostream>
#include <cmath>

using namespace std;

int GetNumberLength(int num){
	int cnt = 0;
	for(;;){	
		++cnt;		
		num /= 10;
		if(num == 0) break;
	}
	return cnt;
}

template <class Container>
void PRINT_ELEMENTS(Container c , const char * preDesciption){
	Container::iterator cit= c.begin();
	cout << preDesciption;
	while(cit!=c.end()){
		cout << *cit++ << " ";
	}
}

template <class atype>
void ArrayDisplay(ostream& out, const atype* ptr, const unsigned int size){
	for(unsigned int i= 0 ; i< size; ++i){
		out<< ptr[i] << " ";
	}
	out<<endl;
}

template <class atype>
atype GetRandom(const atype min, const atype max){
	unsigned int num;
	errno_t err = rand_s(&num);
	if(err != 0) return min;
	if(num % 2 ==0)
		return (atype)(floor((num/(double)UINT_MAX)*(max - min)) + min);
	else
		return (atype)(ceil((num/(double)UINT_MAX)*(max - min)) + min);
}

void GetArray(int * arr, const int size){
	for(int i = 0; i < size ; ++i){
		arr[i] = GetRandom<int>(0, size);
	}
}
#endif